Skip to content

Commit

Permalink
final commit
Browse files Browse the repository at this point in the history
  • Loading branch information
samperrow committed Mar 31, 2018
1 parent 0a0c307 commit 65ea421
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Author: Sam Perrow
* Author URI: https://www.linkedin.com/in/sam-perrow
* License: GPL2
* last edited March 29, 2018
* last edited March 31, 2018
*
* Copyright 2018 Sam Perrow (email : [email protected])
*
Expand Down
4 changes: 2 additions & 2 deletions class-gktpp-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
class GKTPP_Ajax {

public function __construct() {
add_action( 'wp_head', array( $this, 'add_domain_js' ), 1, 0 );
add_action( 'wp_footer', array( $this, 'add_domain_js' ), 1, 0 );
add_action( 'wp_ajax_gktpp_post_domain_names', array( $this, 'gktpp_post_domain_names' ) );
add_action( 'wp_ajax_nopriv_gktpp_post_domain_names', array( $this, 'gktpp_post_domain_names' ) );
}

public function add_domain_js() {
wp_register_script( 'gktpp-find-domain-names', plugins_url( '/pre-party-browser-hints/js/find-external-domains.js' ), null, '1.5.3', false );
wp_register_script( 'gktpp-find-domain-names', plugins_url( '/pre-party-browser-hints/js/find-external-domains.js' ), null, '1.5.3', true );
wp_enqueue_script( 'gktpp-find-domain-names' );

wp_localize_script('gktpp-find-domain-names', 'ajax_object', array(
Expand Down
2 changes: 1 addition & 1 deletion js/find-external-domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ if ( lastScript.match(/find-external-domains.js/) ) {
jQuery.post(ajax_object.ajax_url, gktppDataObj);
console.log(gktppDataObj.urls);
}
}, 1000);
}, 6000);
}
19 changes: 11 additions & 8 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ This plugin allows users to easily embed resource hints from domain names and UR

== Frequently Asked Questions ==

FAQ

How can I determine which URL's to enter?
Go to https://www.webpagetest.org, enter your website's URL, and click on the "waterfall" chart that appears.
a) For all resources that are loaded from external websites or domain names, I recommend inserting a preconnect link for that domain name (Preconnect is more powerful than DNS Prefetch, as it takes care of the DNS lookup, initial connection, and SSL negotiation).
b) If you have a very popular link on your site that you are confident a user would navigate towards, I recommend inserting a link for that URL with the "prerender" option set.
c) Prefetch and preload work similarly, which allows single resources to be loaded before they are requested by the user. Use this for loading images, videos, JavaScript files, etc.

How does the plugin automatically add preconnect hints?
After installing the plugin (or clicking the 'Reset Links' button), a JavaScript file will be sent to your website which captures the resources loaded from external domains and sends them via Ajax to your database. This script fires 6 seconds after the website has been loaded, to allow for all resources to be completely loaded.

Many websites have cache plugins that can interfere with this functionality. I have configured the JavaScript file to only function when it is in its original folder (not been merged/combined). This is to prevent it from triggering after every page load. To get this funtionality working properly, ensure that this file (/wp-content/plugins/pre-party-browser-hints/js/find-external-domains.js) is not effected by any cache plugins.


DNS Prefetch:
For all HTTP requests loaded from external sources on a page web, add the domain name of each in the "Add New Resource Hint" form, select the option for "DNS Prefetch".

Expand All @@ -43,12 +47,10 @@ For all HTTP requests loaded from external sources on a page web, add the domain

If you would like to have preconnect links automatically set, simply install this plugin and allow it do it the magic for you. If you would like this option disabled, just select the option to have these disabled near the bottom of the main plugin screen.

How are the preconnect hints automatically set?
By default, after installing this plugin and loading a page from your website, a JavaScript file will be loaded which searches for the domain names from resources loaded from external domains. These domains are sent via Ajax to your website's MySQL database, which are then used as resource hints for subsequent page loads. If you would like to re-set these links, just click the 'Reset Links' button on the plugin screen.

Preload:
Insert an absolute URL for a CSS, JavaScript, image, etc, and select the option "Preload".

To activate the preloaded resource, you must call that file in HTML as you would any file. For example, if you preload 'jquery.js', you must insert a script tag with a src attribute set to 'jquery.js'. Otherwise the preloaded link will be saved in the browser, but not activated in the DOM.


== Screenshots ==
Expand All @@ -69,15 +71,16 @@ Insert an absolute URL for a CSS, JavaScript, image, etc, and select the option
2. Send me an email at [email protected]



== Arbitrary section ==
Special thanks to Marcus and Paul of [Agent Design](https://www.agentdesign.co.uk) and [Grant](https://grantdb.ca/) for taking the time to test out new features for this plugin and reporting the bugs they've found to me. This saved me from lots of unhappy emails!


== Changelog ==

1. Most recent update: March 29, 2018.
1. Most recent update: March 31, 2018.
2. Version 1.5.3

March 27, 2018:
March 31, 2018:
1) improved automatic discovery of external domains by using the Resource Timing API.
2) cleaned up UI by consolidating form elements and save buttons into one.
3) improved ability for preload hints 'as' attribute to be determined when user inputs data.
Expand Down

0 comments on commit 65ea421

Please sign in to comment.