-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use CSS keyframes via sentinel-js instead of MutationObserver #18
base: master
Are you sure you want to change the base?
Conversation
<html>
<head>
<title>TEST</title>
<meta charset="utf8">
</head>
<body>
<script id="A" type="text/javascript" src="testA.js" async></script>
<script type="text/javascript">
var el = document.getElementById("A");
el.src = 'testB.js';
</script>
</body>
</html> |
@daurnimator Are you concerned about the browser allowing SentinelJS to create a In terms of global style rules, SentinelJS scopes its rules and uses random keys to define animation names so there won't be overlap with other rules: |
Was more thinking about people (perhaps non-technical) being surprised by a
Yep; I saw that. @amorey are you able to tell us much about performance benefits of the sentinel-js approach? We haven't benchmarked yet, but will removing MutationObserver have a big effect? Do you have links to any benchmarks you've done? Or links to info about browser(s) that fall back to a slow path? |
Previously, SentinelJS added The only performance penalties incurred by SentinelJS are normal CSS lookup penalties (from your CSS selector) and one hash key lookup in javascript on If you want to detect nodes added at an arbitrary depth in the DOM then SentinelJS should be much faster than using a MutationObserver to watch for changes to the |
No I don't think so. I'm probably worried about nothing.
We haven't benchmarked yet. i.e. this is mostly premature optimization. However to elaborate on our use case: fengari-web allows you to use lua in the browser just like you use javascript. One feature is that if you create a |
Cool, that sounds like an interesting application. Are you using |
fengari-web/src/fengari-web.js Lines 159 to 161 in e602beb
i.e. we allow |
Great! That's a really nice use of SentinelJS. Please keep me updated on your work! |
This (old) blog post seems to suggest that MutationObserver is faster: http://www.mikehenry.name/2013/06/dom-mutationobserver-performance.html however jsperf links are dead so I can't confirm. Ping @mhenry07 |
Closes #15
I'm a little concerned about sentinel-js's globally visible behaviour: it adds a
<style>
element to the document. I think this wouldn't be acceptable in some contexts e.g. if you're writing a plugin for a page (think an ad or other embedded content)