Preload or prefetch in the link tag uses early fetch request to get the content . This will imply that these resources are fetched earlier and are less likely to block the page's first render, which ulitmately will lead to better page performance. It is generally used where high priority resource must be requested at first that is used in current route.
Preload: W3C released link re=”preload”, which means web developers can now tell the browsers how to load resources on their website.
It gives the developers the capability to assign the custom loading logic without suffering the performance issues which script-based resources loaders draw.
Preload is totally different than the prefetch in the sense that it focuses on current navigation and fetches resources with high-priority.
How To Use:
Preconnect: One of the the easiest ways to speed up your website or application is to simply add preconnect hints for any hosts that you will be requesting assets from. These hints essentially tell the browser what origins will be used for resources, so that it can then prepare things by establishing all the necessary connections for those resources.It helps in resolving handshaking for the DNS and TCP.
How To Use:
Prefetch:Prefetching a process where the browser fetches the resources required to display a specific page that the consumer is likely to get in its second click. In other words, the browser loads a page that you’re probably going to visit in the future. The browser can store these resource in its own local cache,further to send the requested information quicker if the user does end up visiting that page.
It helps to fetch the resource and places it in the cache whenever the resources needs take it from the cache instead of making another request.
while Prefetch focuses on fetching resources for the next navigation which are low priority. It is also important to note that preload does not block the window’s onload event
So below are the two methods explaining how to include a stylesheet in our web page.
The recommmended link tag
The @import rule:
Cascading style sheets are intended to, well, cascade. !important declarations overides the cascading nature of CSS and are frequently viewed as a hack.But like most things proposed to the CSS specifications,!important has a few reasonable applications.
All !important does is increase specificity. If we want to avoid using !important, all we need to do is increase specificity. But doing that can unnecessary destory the original structural and optimise rule of basic stylesheet. It's easy to use unproperly, and it multiply, particularly when misused. One can easily end up with a element with !important rules that you want to override, for which we have to either refactor your styles, or use another !important rule and contribute to the problem.
CSS Expressions are usally depreceated and are used in old browsers.IE for past versions have supported CSS expressions.
What exactly is CSS Expressions-
A typical example for a CSS Expression would be the dynamic calculation for CSS properties which is very easy but heavy.
The objective of this technique is to supplement the link text by adding additional text that describes the technique function of the link and styling the additional text so that it is not rendered on the screen by user agents that support CSS. Whatever the reason, CSS should be used less like any other element.
The best practise for CSS files is that they are typically so small that it's more often faster to download a one larger CSS file instead a number of parallel smaller stylesheets. For every stylesheet link that is used in the body, the browser everytime has to stop and and start the downloads multiple times and that will make a heavy load on the page.
A typical example for this would be.
External style sheets are created in separate documents with a .css extension. An external style sheet is simply a listing of CSS rules. It cannot contain HTML tags. The <link> tag, which goes in the head of an HTML page, is used to link to an external style sheet. There is no limit to the number of external style sheets a single HTML page can use. Also, external style sheets can be combined with embedded style sheets. Follow these steps to create an external style sheet. There are however, times you should limit the use.
WebAnalyzer can analyse all the duplicates links in your webpage so that you can save your wasted page load time and speed for the page.
Most of the "unused CSS" in the project does not get removed and led to this particular factory
Browsers like the IE and Firefox, duplicate JS scripts cause wasted time while evaluating the duplicate scripts more than one time..
Minification is the process that is performed by evaluating,analyzing and rewriting the content of a webpage to reduce its overall size.
It is performed to minimise the size and optimizing the webpage speed. Web Analyzer can give the user's requested css files minified versions. This process is generally performed before a web-application is deployed or just before the production.
So when a user requests a webpage, thr minified version is sent instead of the old version, which ultimately results in the fast-response.
Minification has the direct impact on the server response time or time to first byte.Minification can greatly reduce the overall bandwidth-usage for both the company and the end-user.
E-Tag is a cache headers which servers uses to control how the clients should cache out their content.E-Tags are an alternative to "Last-Modified-Time" for to determining cache validation. With an Etag, it always uses the server to check the hash sum of a file, and only after that will the browser decide take it from the cache or load it completely.For sites where data and files are updating every now and then , it would not be a good practice to use E-Tag .ETag headers should generally not be used unless you have an explicit reason to need them
Adding box shadows is a nice method to conclude the depth and focus to our style. You have probably seen this trick before:
That trick adds a nice box-shadow to any of the selector.
Below is a code snippet that affects the webpage-performance :
A basic way for an element that is used repeatedly on a page, it’s the best way to remove that if its one of the below properties.
This attribute is use to recognise the content between the tags.HTML5 specification has clearly defined and made the attribute free and optional .It is being picked by default.For the most external links, this attribute sometimes used as a way for user agents so that they can avoid fetching resources they do not support.
We should consider replacing the base Woff fonts with Woff2 fonts whenever possible.This would save many kilobytes of size and indirectly speed up the loading page time.One of the important factor is WOFF2 generally has better compression.W3C now recommends font/woff2. Following Browsers are Supported Google Chrome 36 Opera 23 Firefox 39 Opera 23 Edge 14 Safari 12
DNS prefetching is the process that makes the general browser to perform the DNS lookups on the page in the background when the user is surfing or browsing. The process will led to reduce the latency because the DNS lookup has already took place when the user clicks on the link. The syntax for adding DNS prefetching can be added by the syntax rel="dns-prefetch" tag.
A font is a accumulation of glyphs, out of each is a combine set of path explaining describing the letter form. Fonts can be compressed with GZIP or a compatible compressor.When selecting Google Fonts, generally avoid selecting all available styles and character sets just in case.
The unsed selectors or entries in the CSS files increase the page load time at the browser end.The reason being browser have to parse all the unused extra selectors and would take unnecessary load. Web-Analyzer would help you find such selectors so that you can identify the ones and remove them to optimise the website.