I want to share this tip I read some time ago in an HTML parser and have never seen anyone else talk about.
The rendering of a web page implies the process of reading HTML code and displaying on a device's screen. You need to make it easier for the web engine to build the page on a device, using more processor/battery. If you do the frontend and/or the backend, you must make the same rules for ' and " in HTML tags.
Why?
Look at this code,
- <a href='MyPage.aspx?code=id1&customer=1' target="_blanck" title="Some text">
The href tag has ' and the others properties have ". This is very wrong in terms of processing because the code that reads the line needs an alternate between ' and ", quotation mark.
There are many ways to make this URL in the server-side to code the a tag. You can do it in different ways.
The most incorrect way in response (quotation mark and single quotation mark).
- var link = "<a href='MyPage.aspx?code=" + $"id{tId}&customer={cId}" + @"' target=""_blanck"" title=""Some text"">
The almost good way in server-side C#.
- var link = "<a href=\"MyPage.aspx?code=id"+ tId + "&customer=" + cId + "\" target=\"_blanck\" title=\"Some text\">
The best way (interpolation and quotation mark) in C#.
- var link = $"<a href=\"MyPage.aspx?code=id{tId}&customer={cId}\" target=\"_blanck\" title=\"Some text\">
The important thing here is to make all your page quotation marks a single quotation mark. Do not use both in the same HTML tag or in the page. This is very important when you are using AJAX. I have already observed this in practice!
Visual Studio helps to code a quotation mark but only if your code in the server-side is too easy to make a single quotation mark.
The less the processor works to change from ' to ", the faster will be the rendering.
CONCLUSION
This technique is valid to any server-side programming language or pure HTML.
This is not the only way to optimize your HTML but will make it easier for old or powerless devices to render your page faster.
Use the CSS and HTML validators and if you cannot fix it all, fix as much you can,