Skip to content
Advertisement

Load inline JS after page load

I want to load an inline JavaScript after the page has fully loaded. The reason is, that the scripts loads an external JS file which I don’t want to block the rendering of the page.

This is the whole code:

JavaScript

I know that I could maybe use $(document).ready. But I don’t know how.

Advertisement

Answer

The reason is, that the scripts loads an external JS file which I don’t want to block the rendering of the page.

Adding the defer attribute to the script element will defer execution until the DOM is ready while allowing the script to be downloaded in parallel.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement