Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I am writing html for a web portal for my boss and using css (of course) for overall formatting.
First, he told me NOT to use css but to use html includes. My understanding is that html includes are used for html repeated across multiple pages, not for formatting. Also, in my understanding, html includes ALWAYS require js to insert them. Am I wrong? I would be happy to be wrong. I have a day of coding and markup ahead of me, I would like to start it making sense.
There is no such thing as an "HTML include".
There was a proposal for HTML imports but it is dead in the water.
You've tagged this ssi which is a server-side include (which is a standard include mechanism that some HTTP servers support; Apache HTTPD documents it).
Other mechanisms for including HTML include preprocessors like static site generators, templates and include mechanisms provided via server-side programming, and client-side mechanisms involving JavaScript.
The closest HTML itself has to an include is the iframe which lets you embed entire HTML document in a scrolling box in the page. (You can achieve similar effects with object and embed but I'm yet to hear a good reason to prefer them to iframe).
CSS is the correct tool for presentation, but sometimes you need some common HTML scaffolding to apply the CSS to, and sometimes you want to have a single place to include all your presentation meta data (e.g. <link> elements) that gets shared between pages.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Are all the HTML files linked to the same JavaScript file, or do you need multiple JavaScript files? Is there ever a point where you need multiple CSS files?
When it grows large enough :)
Simple websites might only need one HTML file and no separate JS or CSS files. If a site has multiple pages that are returned from the web server, they would need to be separate HTML files (or separate rendered templates, etc.).
If a website or web app has enough JS and/or CSS that it's inconvenient to keep in one file, either because of the load time or the annoyance of editing a file that large, or the complexity of knowing which parts of the file go with which pages or components or templates, that's a good time to split those files in to multiples.
Most modern rich web applications aren't edited/written in terms of the specific files that get served to the browser anymore, instead those end-result files are produced by a bundler like Webpack, FuseBox, etc., into either single or multiple JS (and possibly CSS) files which are dynamically loaded by other internal JS code when they need to be. Smaller and simpler/less interactive websites might have multiple HTML files (or rendered templates) that share the same JS and CSS.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
So recently I have come across a site known as "negafinity", I had looked at it as a normal site, until someone told me that the site was programmed using just JavaScript (presumed they had looked at their .js files).
Site URL: https://negafinity.com/
So, is there any benefit in programming your website in full JavaScript? Rather than just programming it in plain HTML, CSS & JavaScript.
If there is, what are the benefits? And what are the disadvantages?
EDIT: To not make it so broad, I am looking for these main factors:
Website Loading
Programming Time
Caching
Though, I am also on the look out for other benefits/disadvantages so please state them if you feel they are necessary!
When an entire site is created solely with JavaScript, it is most likely because the final HTML and CSS (created by the JavaScript) will always need to be different based on certain conditions.
Those conditions could be something that can only be determined by what the situation is at the server.
Or, it could be based on the type or version of the client that is making the initial request (this would allow for the JavaScript to create proprietary HTML and/or CSS, but only when a certain kind of client makes the request).
Many sites rely heavily on content coming from databases (eBay is a very good example of this) and those sites will often just employ JavaScript to contact the server and get all the information needed and then construct the page based on smaller HTML templates.
In short, it allows for the entire page to be dynamically generated based on current conditions.
However, from a performance standpoint, it would be slower for pages to load this way than to have static HTML and CSS at least for the bulk of the page structure. It would most likely take considerably more time to code the page and less content would be cached.
With today's modern standards like CSS3 Media Queries, page content can be conditionally shown. And with AJAX, portions of a page can be conditionally generated as needed, rather than the entire page being built that way.
I don't think so. There's a reason why most sites use HTML or PHP with javascript.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm looking for simple bullet point answers please. I've tried looking all over, Googling, other questions here but I can never find both advantages and disadvantages for each method.
This is the answer I got from W3Schools pertaining to external javascript files
Pros
It allows separation of concerns - which is not a big deal in simple pages but as the script grows larger you can have a monolithic html page. Big files in general are not ideal for maintainability
It allows caching - when the browser loads a script externally (whether it's be from your site or a cdn) it caches the file for future use. That's why cdn's are preferred for commonly used scripts. Makes the browser use a cached script instead of building a new one every time the page loads which makes the page load faster
More readable code - this ties into the first bullet point but nevertheless it is important. The smaller the files we humans are working with the better. It is easier to catch mistakes and much easier to pass of the torch to the next developer working on the project or learning from it.
Cons
The browser has to make an http request to get the code
There may be other browser specific reasons as well, but I believe the main reason is the separation of code into different components.
Probably the best advantage of using external javascript files is browser caching - which gives you a good performance boost.
Imagine you have a site that uses MyJsFile.js (a random 50kb javascript file that adds functionality to your websire).
You can:
embed it in every page, and add the 50kb to every page request (not ideal)
link it in every page (<script src="MyJsFile.js"></script>)
The second option is usually prefered because most modern browsers will only get the file once, and serve it from the browser cache instead of downloading it at every request.
Check out similar questions:
Why not embed styles/scripts in HTML instead of linking?
When should I use Inline vs. External Javascript?
Is it better to put the JS code on the html file or in an external file?
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Hey, I am a newbie to JavaScript. I really don't know what it does.
What can I do with JavaScript?
What are the possibilities of JavaScript?
What tools will I require to develop in JavaScript?
Is there some plugin available in Eclipse?
Thanks!
Javascript is a programming language.
You can do anything with it that you can do with other programming languages.
As with other languages, you need a text editor and a compiler/interpreter in order to develop with it.
It is mostly used with websites to provide better interaction than HTML can do alone and most web browsers have a built in interpreter for javascript. For security reasons, javascript in the browser is limited (so it can't directly access the filesystem, for example).
See this list of resources for further learning.
Javascript is a programming language used, in context of web sites, to implement behavior function to a page on client side. Using HTML and CSS only, with no Javascript, you can only show things in a pre-defined way. With Javascript, you can control the way things behave.
You can use whatever text editor you like to write Javascript code, and a web browser to run it.
JavaScript is well-suited for performing task within a web browser.It is primarily used to interact with users.
With JavaScript you can do:
it can change HTML content, HTML styles, HTML attributes.
it can detect what browser a person is using and customize the webpages to their browser.
it can validate date.
perform calculation in forms.
validating form input.
interact with multiple frames.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Has anyone here used KSS?
KSS is an AJAX framework.
KSS has both a client-side Javascript library and server-side support.
The client-side Javascript library needs to be included in your page. It fetches Kinetic style sheets from the server, parses them and binds a set of action to browser events and/or page elements. It is clean Javascript code that can peacefully coexist with other clean Javascript librarys(sic) like JQuery or ExtJS. It is about 100k in production mode. You can integrate your own Javascript code by using its extension mechanism through plugins.
I'm currently working on a project that uses it. Are there any drawbacks and gotchas to be aware of?
What's its cross browser support like?
At first as was really put off by the fact that you don't write the JS by hand, and actually translates a CSS-like file to JS behavior, but seeing in action, I've got to say that it really works quite well. But I haven't done any cross browser tests yet.
Some things that I've found:
it sends HTML from the server, instead of XML and/or JSON and replacing them clientside, meaning higher messages (understandable)
it has problems with scripts that add iframes dynamically on a KSS widget that you reload
some things are hard to debug, while others are made easy thanks to KSS' integration with Firebug