@@ -3647,7 +3647,6 @@ Semantic HTML elements provide meaning to the structure of a webpage, making it
36473647<html lang =" en" >
36483648 <head >
36493649 <meta charset =" UTF-8" />
3650- <meta name =" viewport" content =" width=device-width, initial-scale=1.0" />
36513650 <title >Semantic HTML5 Example</title >
36523651 </head >
36533652 <body >
@@ -3766,7 +3765,6 @@ Accessibility is an important aspect of web development, ensuring that web conte
37663765<html lang =" en" >
37673766 <head >
37683767 <meta charset =" UTF-8" />
3769- <meta name =" viewport" content =" width=device-width, initial-scale=1.0" />
37703768 <title >Optimized Website</title >
37713769 </head >
37723770 <body >
@@ -3815,7 +3813,6 @@ Performance optimization is crucial for delivering fast and responsive web exper
38153813<html lang =" en" >
38163814 <head >
38173815 <meta charset =" UTF-8" />
3818- <meta name =" viewport" content =" width=device-width, initial-scale=1.0" />
38193816 <title >Optimized Website</title >
38203817 <link rel =" preload" href =" styles.css" as =" style" >
38213818 <link rel =" preload" href =" script.js" as =" script" >
@@ -3859,7 +3856,7 @@ h1 {
38593856##### Code Example: HTML Minification and Compression
38603857
38613858``` html
3862- <!DOCTYPE html><html lang =" en" ><head ><meta charset =" UTF-8" /><meta name = " viewport " content = " width=device-width, initial-scale=1.0 " />< title >Optimized Website</title ></head ><body ><h1 >Hello, World!</h1 ><p >Welcome to our optimized website.</p ></body ></html >
3859+ <!DOCTYPE html><html lang =" en" ><head ><meta charset =" UTF-8" /><title >Optimized Website</title ></head ><body ><h1 >Hello, World!</h1 ><p >Welcome to our optimized website.</p ></body ></html >
38633860```
38643861
38653862[ ![ Edit 105-HTML Minification and Compression] ( https://codesandbox.io/static/img/play-codesandbox.svg )] ( https://codesandbox.io/p/sandbox/105-html-minification-and-compression-vdpynt )
@@ -3873,19 +3870,9 @@ h1 {
38733870##### Code Example: Lazy Loading of Images
38743871
38753872``` html
3876- <!DOCTYPE html>
3877- <html lang =" en" >
3878- <head >
3879- <meta charset =" UTF-8" />
3880- <meta name =" viewport" content =" width=device-width, initial-scale=1.0" />
3881- <title >Optimized Website</title >
3882- </head >
3883- <body >
3884- <h1 >Hello, World!</h1 >
3885- <img src =" placeholder.png" loading =" lazy" alt =" Lazy Loaded Image" >
3886- <p >Welcome to our optimized website.</p >
3887- </body >
3888- </html >
3873+ <h1 >Hello, World!</h1 >
3874+ <img src =" placeholder.png" loading =" lazy" alt =" Lazy Loaded Image" >
3875+ <p >Welcome to our optimized website.</p >
38893876```
38903877
38913878[ ![ Edit 106-Lazy Loading of Images] ( https://codesandbox.io/static/img/play-codesandbox.svg )] ( https://codesandbox.io/p/sandbox/106-lazy-loading-of-images-mx2q9r )
@@ -3908,7 +3895,6 @@ h1 {
39083895<html lang =" en" >
39093896 <head >
39103897 <meta charset =" UTF-8" />
3911- <meta name =" viewport" content =" width=device-width, initial-scale=1.0" />
39123898 <title >CSS and JavaScript Optimization</title >
39133899 <link rel =" stylesheet" href =" styles.min.css" >
39143900 </head >
@@ -3958,36 +3944,26 @@ HTML5 introduces a multitude of APIs that empower developers to create sophistic
39583944The Geolocation API enables web applications to access the user's geographic location, providing valuable information for location-based services and applications. Developers can use this API to retrieve the user's current position, monitor changes in position over time, and calculate distance and direction between locations. This functionality opens up possibilities for location-aware features such as mapping, local search, navigation, and location-based notifications.
39593945
39603946``` html
3961- <!DOCTYPE html>
3962- <html lang =" en" >
3963- <head >
3964- <meta charset =" UTF-8" />
3965- <meta name =" viewport" content =" width=device-width, initial-scale=1.0" />
3966- <title >Geolocation API</title >
3967- </head >
3968- <body >
3969- <p >Latitude: <span id =" latitude" ></span ></p >
3970- <p >Longitude: <span id =" longitude" ></span ></p >
3947+ <p >Latitude: <span id =" latitude" ></span ></p >
3948+ <p >Longitude: <span id =" longitude" ></span ></p >
39713949
3972- <script >
3973- if (navigator .geolocation ) {
3974- navigator .geolocation .getCurrentPosition (
3975- function (position ) {
3976- document .getElementById (" latitude" ).innerHTML =
3977- position .coords .latitude ;
3978- document .getElementById (" longitude" ).innerHTML =
3979- position .coords .longitude ;
3980- },
3981- function (error ) {
3982- alert (" Error getting geolocation: " + error .message );
3983- }
3984- );
3985- } else {
3986- alert (" Geolocation is not supported by this browser" );
3950+ <script >
3951+ if (navigator .geolocation ) {
3952+ navigator .geolocation .getCurrentPosition (
3953+ function (position ) {
3954+ document .getElementById (" latitude" ).innerHTML =
3955+ position .coords .latitude ;
3956+ document .getElementById (" longitude" ).innerHTML =
3957+ position .coords .longitude ;
3958+ },
3959+ function (error ) {
3960+ alert (" Error getting geolocation: " + error .message );
39873961 }
3988- </script >
3989- </body >
3990- </html >
3962+ );
3963+ } else {
3964+ alert (" Geolocation is not supported by this browser" );
3965+ }
3966+ </script >
39913967```
39923968
39933969[ ![ Edit 108-Geolocation API] ( https://codesandbox.io/static/img/play-codesandbox.svg )] ( https://codesandbox.io/p/sandbox/108-geolocation-api-443vqt )
@@ -4010,10 +3986,16 @@ The Web Storage API provides a mechanism for storing key-value pairs locally wit
40103986localStorage .setItem (" username" , " John" );
40113987
40123988// Retrieve data from local storage
4013- var username = localStorage .getItem (" username" );
4014- console . log (" Username: " + username);
3989+ const username = localStorage .getItem (" username" );
3990+ alert (" Username: " + username);
40153991```
40163992
3993+ [ ![ Edit 109-Web Storage API] ( https://codesandbox.io/static/img/play-codesandbox.svg )] ( https://codesandbox.io/p/sandbox/109-web-storage-api-729wnm )
3994+
3995+ - [ ^ 109 ] CodeSandbox: Web Storage API.
3996+
3997+ [ ^ 109 ] :[ CodeSandbox: Web Storage API.] ( https://729wnm.csb.app/ ) , last access: September 30, 2024.
3998+
40173999- The code above demonstrates how to use ` localStorage ` to store and retrieve data.
40184000- The ` setItem() ` method is used to store a key-value pair ("username" and "John") in local storage.
40194001- Later, the ` getItem() ` method retrieves the value associated with the "username" key, which is then logged to the console.
0 commit comments