Search code examples
javascripttypescriptsystemjs

System.config() call on <head> or <body>?


I usually like to add my tags to the bottom of my page. But on a lot of the examples that I see online, the call to Systemjs's config is on the tag. I've moved the System.config() script to the bottom of the page, and everything still works as expected.

So my question is... Will I encounter any issues by putting the System.config() call at the bottom of the page, or is it safe to do so?

Thanks for the help! :)


Solution

  • The reason why it's recommended to have JavaScript code at the bottom of the HTML page is so it only runs after the document has been loaded.

    SystemJS, like many JS libraries, have a fallback for this already in their framework so it doesn't matter much where you add the <script> tag.

    Example of this would be jQuery's $(document).ready( ... ); wrapper.