File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 177177</ div >
178178
179179< script >
180- maplibregl . accessToken = "pk.eyJ1IjoidHJpc2NodGFuZGVyIiwiYSI6ImNsNmZwNXY2MDAxOWEzZG41b213NWJ2ZjIifQ.pMjBga8kA5XQuDw19WQ8TQ" ;
180+ // Defer heavy map initialization until after critical rendering
181+ function initializeMap ( ) {
182+ maplibregl . accessToken = "pk.eyJ1IjoidHJpc2NodGFuZGVyIiwiYSI6ImNsNmZwNXY2MDAxOWEzZG41b213NWJ2ZjIifQ.pMjBga8kA5XQuDw19WQ8TQ" ;
181183
182184var map = new maplibregl . Map ( {
183185 container : "map" ,
@@ -433,5 +435,14 @@ <h3 class="name-popup">${properties.name}</h3>
433435 preload ( ...{ { thumbnails } } ) ;
434436}
435437
438+ } // End of initializeMap function
439+
440+ // Initialize map after critical rendering, or when browser is idle
441+ if ( window . requestIdleCallback ) {
442+ requestIdleCallback ( initializeMap ) ;
443+ } else {
444+ setTimeout ( initializeMap , 100 ) ;
445+ }
446+
436447</ script >
437448{% endblock %}
You can’t perform that action at this time.
0 commit comments