I have a website that is written using cgi/perl, html, js, css. I would like to know how the webpage loads in the browser? Will it load in the same order it is coded?or which one has more priority and whether it will be browser dependable?Please let me know if I need to be more clear.
All HTML documents load from top to bottom. CSS loads in the order it is called, but it has special rules about what overwrites what and what rules are more important than other rules. LINK
JavaScript that is embedded in an HTML doc gets run as soon as its loaded.
Now CGI/Perl I am not entirely sure how it runs as I have not dealt with it really. I would assume it loads as it is called, unless its an interpreted language like PHP. PHP is ran before the page is actually loaded on the client machine. The end user just gets to see the pretty page and none of the code.
Server-side languages are called first, before the page loads. Then the output of the server-side script is sent to the browser as HTML. If you view the page source, you'll see what I mean.
Everything else is done in top to bottom order then.
The only important thing to grasp is that while server-side scripts and client-side scripts are called from top to bottom, the server-side ones are done first on the server before the browser gets any content, and then the output of server-side scripts is sent to the browser to be executed.
Great wit and madness are near allied, and fine a line their bounds divide.
thanks a lot to both of you. I have one general question before I am convinced
If my code(.cgi) is written like this:
perl code - Includig header/navbar/footer
perl code - db connection.
perl code - some coding
html code - css/js includes
html code - using the perl variables here and there to show the content/footer
So in the above scenario, the perl code is executed first and then the output is shown in the browser as html then its followed/loads the html code sections(js/css...)?
All the Perl is executed first from the top down, and then the browser executes the HTML. If you want to see what the browser does, view the page source in the browser. View -> Page Source, and I think CTRL + u is the shortcut in Firefox anyway. On the HTML side, JavaScript and CSS are loaded as they appear in the page.
Great wit and madness are near allied, and fine a line their bounds divide.
Bookmarks