Sven Grossenbacher

How to get inline javascript out of HTML

2 posts in this topic


I am developing clean fast loading sites with no inline Javascript inside the html but unfortunately your component uses Javascript inside HTML ...

When a browser encounters a script element during the parsing of a page's HTML the following happens:

  • The browser pauses processing of the HTML.
  • The browser initiates an instance of its Javascript interpreter.
  • The Javascript interpreter compiles the Javascript and adds it to the current page's global Javascript pool.
  • The browser continues parsing the HTML, repeating 2. and 3. as many times as there are script elements in the HTML.

So, having multiple script elements will slow down rendering of the page. The fewer scriptelements present in the HTML the faster the page will render.

Can you take those script out and put them where they should be? This works as it is but it is not really what my client expects in a site I develop for him

Share this post

Link to post
Share on other sites

Hi Sven.

Thanks so much for using our extension.

But it is hard to avoid using inline javascript because sometime we must get data from website configuration, it mean we must using PHP, then pass data to javacript.

So using inline javascript is easy way.

But if you really want to use javascript file you can custom the code to create js file by PHP, then put javascript string to this file and add it with Joomla Function.


Share this post

Link to post
Share on other sites