-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Proposal: to add a noblock type to script tags #4529
Comments
This use case makes sense, but we already have a mechanism to support this: web workers. In other words, instead of <script type=noblock src="foo.js"></script> you'd do <script>new Worker("foo.js");</script> In my opinion the latter (existing) solution is clearer and more explicit. The noblock version is a bit weird, because it's strange to include a script via a script tag and have that script not operate in the same JS realm as the document. |
Thanks for replying quickly. Actually I can see the workers covering at least half of the use cases but what I meant was including this big JS file and for example attaching it to <script type=noblock src="foo.js" onload="fooLoaded(event)"></script>
<script>
function fooLoaded(loadEv){
window.foo.whatever();
}
</script> I get this can be implemented with dynamic For example the runtime of angular abstracted without DOM access which can get quite big. |
We can't allow access to |
Yeah, we can't do this. You're either in a worker or in the main thread (same thread as the rest of the DOM). DOM isn't thread safe / threadable. |
@ahmedHusseinF what kind of functionality do you want to access on window "in parallel" that isn't in workers? |
Currently we have 3 types of including scripts in an html page:
But sometimes I have huge JavaScript files that has nothing to do with the DOM and it is either blocking HTML parsing or waiting.
This proposal propose adding an option to download and parse and execute JavaScript in parallel to HTML parsing by adding a specific option on the script tag and this can let me mangle with just JavaScript code as long as my script doesn't touch the DOM.
This is my first time making a big open source contribution, so I am open to any critique or directing me in the correct direction if this doesn't look good.
The text was updated successfully, but these errors were encountered: