Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-02-07 14:47:02

towndock
Member
From: Oriental, NC USA
Registered: 2007-04-06
Posts: 329
Website

Defer loading Textpattern form

I have a site that loads map data on certain pages. The map is selected by a tab.

Example page: http://marineweather.net/coastal/boston-harbor-coastal-forecast

Everything on the page loads initially, although the map is not seen by a site visitor unless they click the map tab. The map is a cool feature, but it’s size means that 90% of a page load is loading that map. I’m seeking to make page loads snappier.

The data that creates the map is all on a Textpattern form. It includes js & css & json files. The Textpattern form is useful as there are TXP tags used that make the map unique to every page it is used on. As a result, I’d like to continue to use the form.

Is there a way to delay loading a Textpattern form? A delay of 2 seconds for example would make page loads faster, while still providing the map to those who use it well ahead of when they would likely click the map tab.

Offline

#2 2018-02-07 16:40:26

kuopassa
Plugin Author
From: Porvoo, Finland
Registered: 2008-12-03
Posts: 230
Website

Re: Defer loading Textpattern form

I would create a separate page for the Map tab, but there are also couple other things to consider:

Source code in Boston Harbor Marine Forecast page suggests jQuery library is loaded several times:

First time:
<script type="text/javascript" src="https://code.jquery.com/jquery.min.js"></script>

Second time:
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>

Third time, perhaps:
<script>window.jQuery || document.write('<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">\x3C/script>')</script>

Then there are couple fonts that are loaded one by one. They can be smushed together like this:

<link href="https://fonts.googleapis.com/css?family=Oswald:300,400|Roboto" rel="stylesheet">

Offline

#3 2018-02-07 16:40:31

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Defer loading Textpattern form

Your page speed is not too bad, see the Pingdom Tools report

From that there are a few areas of note, which would probably be better gains than trying to delay Textpattern loading:

  1. The JSON files from mwx-13bc.kxcdn.com/jsonpoly/ make up over half the page weight – can you cache those for a certain amount of time (say 5 minutes or preferably more) using a plugin like etc_cache – see how I do something similar to throttle the GitHub API for Textpattern.com here
  2. You seem to be loading two separate versions of jQuery?
  3. Consolidate Google Fonts into one HTTP request roughly like so: <link href="https://fonts.googleapis.com/css?family=Oswald:400,300|Roboto:300,400,500,700" rel="stylesheet">
  4. You may be able to reduce that render blocking 1s wait and load for mwx-13bc.kxcdn.com JSON items by preloading?

Offline

Board footer

Powered by FluxBB