Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can A Static Website Consist of JavaScript?

Can a website with JavaScript consider as a static website? Or static website can only consist of pure HTML without JavaScript?

like image 901
Andrew Lam Avatar asked Jun 09 '17 13:06

Andrew Lam


People also ask

What is included in static website?

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.

Can you make a full website with JavaScript?

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.


2 Answers

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

like image 103
Daniel Schmidt Avatar answered Oct 06 '22 00:10

Daniel Schmidt


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 ;)

like image 21
Stf_F Avatar answered Oct 05 '22 23:10

Stf_F