This question already has answers here:
What are the advantages and disadvantages of using a content delivery network (CDN)? [closed]
(4 answers)
Closed 7 years ago.
I am trying to write a JavaScript script to populate HTML using jQuery and Bootstrap. In many tutorials on the internet, tutors mention to using files from a Content Delivery Network(CDN) instead of calling those files locally.
But I am unable to foresee any advantage making a call to js or CSS over a network, instead of loading it locally, which should prove good enough.
I am eager to know, what is the difference in terms of network and machine resources as well as the load on a page.
Pros using CDN:
* cache for the library in the client side.
Cons using CDN:
* If the cdn's site is down, your site will not get the files.
* Cdn file changes frequently and therefore your production site will work with the newest files that you didn't checked them(this can be very dangerous).
Now you can think if this suitable for your site.
Related
This question already has answers here:
How can I force clients to refresh JavaScript files?
(30 answers)
Closed 2 years ago.
The design of our website is such that whenever we make some changes in CSS & JavaScript files we require the user to clear the browser cache and get the latest version of these files from the server. This is highly undesirable from the user perspective and I don't see well designed websites out there having this issue.
Are there any website design best practices that can be followed to minimize this issue? Any pointers would be appreciated.
Check out more on cache-busting. When you make changes to your css and javascript, you can append a version type to force the browser to reload the document.
Example:
<script src="myjavascript.js?v=1.1"></script>
<script src="myjavascript.js?v=1.2"></script>
etc : )
This question already has answers here:
Local file access with JavaScript
(14 answers)
Closed 3 years ago.
I try to display windows explorer view as a static web page. We have to read a root folder and display all the folders and files as a static webpage. We have to use only client side programming. I know it is possible with the help of server side programming. My question is, is it possible to achieve it in front end without involving backend. I have only one problem which is reading the folder structure. How can I do it? I need to load a html file(ex..C:\workspace\treeview\index.html) in the browser and it should display all the files and folder. Also share your suggestions to achieve the above scenario?
The short answer here is no. Browsers are disallowed from accessing the local file system in this way. Even a simple iframe with a local src will throw errors in the Console.
<iframe src="C:\" width="600" height="480"></iframe>
Without getting into (or fully understanding) them, there are severe security implications if JavaScript is allowed to access the local filesystem. Imagine how dangerous malicious JS code could be if it was allowed.
This question already has answers here:
One big javascript file or multiple smaller files? [duplicate]
(7 answers)
Closed 6 years ago.
I have 4 types of js file and here are the list:
bookmark.js, status.js, auth.js and photo.js
Question:
Should i load the js only for specific page or i will compile everything into 1 js?
Does affect loading webpage if i use specific js for each page?
So, it depends, exactly in what you're looking for.
In case you're looking for loading speed, I think the best solution is keep them separated, it will allow the browser to load more than one js file asyncronusly.
But, if you need to have smartest code you should keep them in one single file, trying to reduce it more and more.
Remember that you should only think about this on your production code, absolutely is better to have different file working on them.
As you can see if you try the first approach you'll be more fast on page load. An example is a web application who need to load big amount of js files.
loading 3 file of 1MB will be always more fast that loading a single one of 3MB because they will start their loading in the same time.
Another approach is to load js files when your page requires them, but remember that in this case, if you have big js files, the client will see a lot of loadings during his surf on the website your working on.
Here you can read more about js file managment
Are you using any JavaScript front-end framework like AngularJS? If you really only want to include the required JS files you can do that.
In case all html pages use separate javascript files, its better to keep them separate. Based on users action they will be cached on browser end.
To optimize load time you can do the following
Use async inside your script tags so its not blocking rest of the
page and,
Use javascript minification on all of them this will reduce the size of the file and reduce the http payload.
This question already has answers here:
Why should I use Google's CDN for jQuery?
(7 answers)
Closed 7 years ago.
At some point in my website I needed a Timer so I looked for a free jQuery Countdown Timer and found this one : Example
After integrating the model to my page inside my IDE (VS2010) i payed attention that some CSS and JS files are not stored locally in my project folder, but they are still Linked to an External sources, and that had me thinking : Am i suppose to find a way to download these file locally than use them, or should i use them the way they are ? and should i be concerned if they may change or desperate at some point in the future ? what are the best practices in case ?
Here is an example of the HTML code :
....
....
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<script type="text/javascript" src="inc/TimeCircles.js"></script>
....
....
Those are CDNs ( http://it.wikipedia.org/wiki/Content_Delivery_Network ) meaning that they're hosted by someone for all of us to use, so you're pretty much guaranteed it will stay there. The main advantage of using CDNs is that the user will probably have visited another site that uses the same resource and this means that said resource is already cached in the user's computer, leading to a faster loading time for your site.
You should never rely on external sources for critical files unless you're using a dependable CDN. In this case you're using the most common CDN sources for Bootstrap and jQuery, so you're all set.
I assume that you've downloaded the timer files and are hosting those locally. Your reference to them confused me, so I've updated this answer.
This question already has answers here:
Convert a PHP script into a stand-alone windows executable
(7 answers)
Closed 9 years ago.
I want to make windows standalone app with php, even i want to use database, javascript in that application.
Note : i don't want to give source code to user.
I should be like exe file which user can run.
If going with Windows, try WinBinder. It allows you to develop native Windows applications using PHP.
It also supports SQLite, so you don't need a database server
Also this answer will help you
I use phc to create .exe files out of my PHP source code. It works quite well, but it's mostly good for console applications rather than full webpages.
However, you could have your PHP script include a basic "server" that allows the browser to communicate with it - I have done this in the past too, and while it might seem daunting the results were very rewarding.