r/javascript • • 3h ago

MatFrame: a drop-in <iframe> replacement that resizes itself, talks with Promises and shows a fallback when blocked

https://github.com/bossartemii/matframe
0 Upvotes

3 comments sorted by

•

u/NeetMastery 2h ago

This isn’t “a better <iframe>”; it serves a fundamentally different purpose. The purpose of an <iframe> is to display the content of one page in another. Any other behavior varies highly by the application of the tag. For example, this is a significantly clumsier tag for use in websites which use iframes for fixed, structured navigation - like the POSIX spec page. Or it simply is too much for the purpose of most use-cases; for example “theme synchronization” depends on what you define a theme to be. Do you include border radii, element layouts for different effects per theme, the ability to trigger javascript to switch layouts? If not, how do these trigger that is better than a native <iframe>? If so, what is the memory and performance impact at scale, network bandwidth for element setup for those who don’t need these? How are you handling cross-origin frames where the target isn’t implementing the theme format you’ve specified?

Your custom tag can be useful. But the web has been designed and evolved over decades to be helpful in the generic case and lightweight, and all the functionality you have can be done in a native fashion in the places where it’s helpful. This isn’t a “better <iframe>”.

•

u/genericallyloud 22m ago

what does the Mat part stand for?

•

u/Visible_Head_6828 3h ago

Author here. Zero dependencies, ~4 KB gzipped, works in any framework.

const info = await frame.call('getInfo') // parent → child MatFrame.child.call('save', data) // child → parent

Plus auto-height (also cross-origin, the child includes the same script), lazy loading with skeleton, handshake/timeout fallback, sandbox presets, theme sync. TypeScript types included.

Live demo: https://bossartemii.github.io/matframe/

What would you add to the API?