Can a website with JavaScript consider as a static website? Or static website can only consist of pure HTML without JavaScript?
What is a static website? A static website consists of a series of HTML files, each one representing a physical page of a website. On static sites, each page is a separate HTML file. When you visit the homepage, you are viewing only the actual homepage file.
In short, JavaScript is a programming language that lets web developers design interactive sites. Most of the dynamic behavior you'll see on a web page is thanks to JavaScript, which augments a browser's default controls and behaviors.
tl;dr if the javascript code manipulates the DOM like a SPA does, it is a client-side dynamic webpage.
As far as the required server infrastructure is concerned, a website with JavaScript can still be considered static because it can be hosted by static hosting services (no server code involved).
But with the extensive use of JavaScript for Client-Side Rendering in Single Page Applications (SPAs) we have to introduce a second dimension of that classification: The way the Document Object Model (DOM) is generated in the browser.
With traditional static webpages the DOM is generated by the browser by parsing an HTML file. Pure static websites which just consist of HTML and maybe some simple JavaScript are therefore static in terms of hosting and DOM generation. In SPAs the DOM is generated by JavaScript creating and manipulating DOM Nodes through the DOM API. Typical SPAs are therefore static in terms of hosting, but dynamic in terms of DOM generation.
Blogpost: The Static Site Awakens and Strikes back
A static site can use javascript. If you use bootstrap for the front-end it will come with js libraries that enhance the UX and look'n'fell for instance. A dynamic site is a site with a server side language (php, python etc.) You could therefore have a dynamic site without javascript ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With