=== Pre* Party Resource Hints ===
Contributors: samperrow
Donate link: https://www.paypal.me/samperrow
Tags: DNS prefetch, prerender, preconnect, prefetch, preload, performance, speed, resource hints
Requires at least: 4.4
Tested up to: 6.3.1
Stable tag: 1.8.20
Requires PHP: 7.0.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Take advantage of browser resource hints and plug-and-play features to improve page load time.

== Installation Video ==

[youtube https://www.youtube.com/watch?v=Aha9E3AXvJQ]

== Description ==

This plugin allows users to automatically and easily embed resource hints to improve page load time.

DNS prefetch, prerender, preconnect, prefetch, and preload are all supported.

After installation, preconnect hints will automatically be created the next time your website is visited.

You have the choice to include these resource hints in the HTTP header or the website's <head>.

== Installation ==

1. Upload the entire `pre-party-browser-hints` folder to the `/wp-content/plugins/` directory.
2. Activate the plugin through the 'Plugins' menu in WordPress.

== Frequently Asked Questions ==

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 loaded on your website (after a page is loaded) which captures the resources loaded from external domains and sends them via Ajax to your database six seconds after the page has been loaded. 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/preconnect.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".

Prefetch:
Insert an absolute URL for a CSS, JavaScript, image, etc, that is hosted on an external domain, and select the option "Prefetch".

Prerender:
Insert a valid URL that a visitor to your website is likely to visit, and select the option "Prerender". The URL you entered will now be loaded by the browser after all requests have been loaded on the page.

Preconnect:
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 "Preconnect". Preconnect is more powerful than DNS Prefetch, because it resolves three connections instead of one.

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.

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 ==

1. screenshot-1.png

2. screenshot-2.png

3. screenshot-3.png

4. screenshot-4.png


== Changelog ==
1. Most recent update: February 17, 2024
2. Version 1.8.20

February 17, 2024:
1) updated sql query to prevent sqli issue.

January 13, 2024:
1) fixed sql injection issue.

November 11, 2023:
1) ensured compatibility with WP 6.4+
2) made small change to plugin activation process and file structure.

October 6, 2023:
1) maintenance update.

July 22, 2023:
1) updated to ensure compatibility with WP 6.3+

Jan 15, 2023:
1) updated to ensure compatibility with WP 6.1+
2) updated unit tests

May 16, 2022:
1) ensured compat with WP 6.0

Jan 23, 2022:
1) ensured compatibility with WP 5.9.0

Dec 7, 2021:
1) Fixing two bugs relating to compatibility with other plugins.
2) the database table will be deleted when uninstalling plugin.

Nov 16, 2021:
1) Adding compatibility for Pre* Party Pro. When activated, the Pro version allows for resource hints to be added to specific posts, automatically generated prerender, preconnect, and preload hints for each post.
2) Improved plugin architecture also.

Sept 7, 2021:
1) Changed minimum role capability required to use this plugin from "update_plugins" to "manage_options" to address a plugin compatibliity error ("Disable All WordPress Updates").
2) Updated/added support for translations.
3) Changed hint creation process to use back end validation/config instead of client side JS.
4) Split up "auto preconnect" code into two classes for admin and client side roles.
5) Split "Utils" class into two Utilities classes, and modified namespaces.
6) Improved JSON parsing.

August 18, 2021:
1) Fixed/improved numerous things.

August 9, 2021:
1) Fixed JSON parsing error which happened for < PHP 7.3 users. Thank you to the users who pointed it out.

July 30, 2021:
1) fixed JS error from "auto prefetch" feature.

July 26, 2021:
1) Fixed error preventing new hint attributes from being selected/unselected as they should be.

June 29, 2021:
1) fixed some bugs relating to prefetch settings, and auto preconnect.

June 23, 2021:
1) converted settings sections to be meta boxes.
2) numerous other updates, tweaks, changes.

April 23, 2021:
1) Fixed bug preventing users from selecting crossorigin and media attribute.

April 22, 2021:
1) fixed small bug which occurs when editing existing hints.

April 18, 2021:
1) Fixed issue updating hints, setting the proper attributes, and hint verification.
2) Made minor changes to UI.

March 28, 2021:
1) fixed issue updating hints.
2) fixed issue with type_attr not saving properly.

March 23, 2021:
1) replaced missing "Reset" button for auto-preconnect hints.
2) optimized CRUD operations for db table.

March 15, 2021:
1) added 'Media' attribute/column field (for preload hints).
2) organized/cleaned up Settings page UI.
3) organized architecture of codebase, incoorporated lots of unit tests.

December 23, 2020:
1) fixed issue with creating hints, and made the hint creation process more uniform.
2) added support for the ".webm" video type
3) improved testing, error handling, a few other architectural adjustments.

December 13, 2020:
1) Updated/simplified class names and removed/added some classes
2) Organized architecture
3) added the ability to automatically prefetch hints (thanks to Gijo Varghese, who allowed me to borrow his Flying Pages
   JS script)
4) ensured compatibility with WP 5.6

December 13, 2020:
1) Updated/simplified class names and removed/added some classes
2) Organized architecture
3) added the ability to automatically prefetch hints (thanks to Gijo Varghese, who allowed me to borrow his Flying Pages
   JS script)
4) ensured compatibility with WP 5.6

November 29, 2020:
1) Ensured compatibility with WP 5.6.
2) Added automatic preload hint creation upon hover on front end.
3) Put all database calls into a single file for better organization, testing abilities (DAO model)
4) cleaned up/organized other parts of plugin.

September 27, 2020:
1) Added more information about how the "auto-preconnect" feature works.
2) Cleaned up and added better management of hint creation/update/deletions.
3) Removed some unneeded code.

September 5, 2020:
1) Modified how auto-preconnect hints are sent by requiring that they be used within six hours of their initiation.
   Sometimes that file gets cached, and its filename changes by other plugins, and constantly fires requests.
2) Made minor changes to HTML on pages and file paths.

August 3, 2020:
1) tested WP 5.5 compatbility
2) corrected bug with updating hints
3) simplified the sending of and creation of frontend hints
4) Adjusted translations

July 7, 2020:
1) Replaced hardcoded "wp-admin" URL's with dynamic ones.

June 4, 2020:
1) Fixed plugin compatibility issue.

June 3, 2020:
1) added ability to edit existing hints inline asynchronously.
2) adding, updating, and deleting hints is now 100% ajax driven.
3) navigating between tabs will toggle that content's display, instead of including each tab file.
4) various other improvements to code to improve functionality.

April 15, 2020:
1) fixed URL encoding issue.
2) plugin update issue.

February 2, 2020:
1) added warning when a cache plugin is active and users choose HTTP header option to let them know to clear cache.
2) Ensured compat w/ WP 5.3.2

December 8, 2019:
1) Re-added option to allow resource hints to be sent in the HTTP header.
2) Small bug fixes

November 4, 2019:
1) Ensured compatibility with WP 5.3
2) Removed debug console.log message on preconnect.js; other minor change to that file.

October 5, 2019:
1) Entered URL's will no longer be converted to lower case. This is because some sites have case-sensitive URI's.

September 28, 2019:
1) Fixed bug with preconnect-ajax hints.
2) fixed issue with upgrading db table from v 1.5.8

September 15, 2019:
1) Dramatically reconfigured plugin. Version 1.6.0 is basically a complete rewrite of all code used. It is more organized, concise, efficient, easy to understand, simple, and user friendly than previously.
2) The option to add hints in the HTTP header has been removed. This is necessary because that feature will not be compatible with future versions of the plugin.
3) Moved all plugin settings to the "Settings" tab for easier navigation.
4) Added ability for users to set the crossorigin, as, and type attributes for hints.
5) Transformed "Contact" box into a pop up modal.

February 16, 2019:
1) Ensured compatibility with WP 5.1
2) Removed legacy file
3) Made minor syntax changes.

October 19, 2018:
1) Tested compatibility with WP 5.0
2) Tested up to PHP 7.3.0.
3) Updated github URL.

August 9, 2018:
1) Added a warning indicator on the admin page to let users know that they should not load hints in the HTTP header if they have a cache plugin active, and to notify them to refresh their cache.
2) Removed the need for jQuery to be loaded dynamically in the "preconnect.js" script, and optimized the code. 100% vanilla JS now!
3) In the "Request New Feature or Report a Bug" feature, I added some info that gets sent to me to better diagnose potential plugin problems (WP version, PHP version, URL).

June 29, 2018:
1) updated a change in my GitHub username onto file paths that display HTML links on the info tab.
2) Created a plugin installation video and put it on the readme


April 27, 2018:
1) fixed bug preventing users from deleting or updating resource hint statuses.
2) fixed bug some users could notice upon installation/reactivation in the admin.php file.

April 14, 2018:
1) Fixed some UI issues on admin page (URL input field not taking up max space, jQuery sometimes not loading).
2) removed check to see if JS preconnect hint array had items before sending it to db (if it was empty, this caused the script to keep firing over and over).
3) changed some text in description.
4) cleaned up old variable's on class-PPRH-display-items.php file.

April 2, 2018:
1) removed unneccessary call on admin side for creating table.
2) fixed some bugs relating to how URL's are inserted and how the crossorigin attribute is created.
3) fixed bug in creating the header string.
4) fixed bug relating to how user options were saved on admin side.

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.
4) improved sanitization and overall URL entry process.
5) cleaned up the code which governs how hints are delivered from the db to the browser.
6) 'crossorigin' attribute is now determined on the back end.
7) added more detailed information to the Preload information section.
8) modified db table schema- added 5 columns: 'as_attr', 'type_attr', 'crossorigin', 'header_string', and 'head_string' for those respective attributes which browsers are getting more particular about. The last two columns are helpful for storing the specified links in the db, and delivering them very quickly to the browser.
9) the improvements above have been able to bring total PHP execution time on the front end down to around 0.07-0.1 milliseconds (that's 0.00007 seconds). Essentially I am shifting more of the calculations/computations to the back end when the user inputs data rather than the front end.

Feb 26, 2018:
1) modified call order of admin.php functions
2) fixed SQL bug that occurred while deleting previous ajax hints

Feb 19, 2018:
1) Added ability for multisite install's to create a plugin table for each site upon creation.
2) Added ability for multisite install's to delete the plugin table(s) for each site upon deletion.

Feb 4, 2018:
1) Optimize performance by forcing the PHP files that are needed only on the FE to be loaded only on the FE and same for BE PHP files. Doing this allowed code execution to be reduced from ~6 milliseconds to ~1 millisecond!
2) Cleaned up some code to reduce amount of code.
3) Tested compatibility with WP 4.9.2

Dec 22, 2017:
1) fixed small issue with setting the 'crossorigin' attribute.

Nov 17, 2017:
1) fixed bug preventing resource hints from appearing in the WP admin HTTP header

Nov 14, 2017:
1) Tested compatibility with WP 4.9
2) Fixed some issues with the resource hint output for the HTTP Header option
3) Fixed bug that threw an error when inserting hints
4) fixed bug that prevented plugin from being deleted properly
5) Changed how the "as" attribute was being set for preload hints.

Oct 7, 2017:
1) Improved code, changed some variable names
2) renamed class names to be consistent with WP coding standards.
3) added option to remove auto generated WP resource hints.
4) segmented each <form> to have its own method.
5) updated HTTP Header string to make it compatible with the most recent Chrome version and incorporate the 'as' attribute.

Sept 20, 2017:
1) fixed bugs due to WP 4.8.2 changes.

Sept 13, 2017:
1) improved code on class-PPRH_Send_Entered_Hints.php
2) added two more screenshots of the before and after effects of implementing this plugin.

July 13, 2017:
1) added a form on plugin admin screen to contact author about feature requests or bug reporting;
2) fixed minor issue with the preconnect JS script not firing;
3) fixed minor UI issues/CSS;

July 6, 2017:
1) added ability to choose to add links to the Header or <head>;
2) cleaned up UI;
3) fixed bugs on preconnect.js/ improved functionality;
4) removed option to select which pages/posts the links went to- this was unwanted feature and removing it improved performance
5) condensed the info tab links into one;
6) modified schema for PPRH_table; and removed the other table;
7) improved security;

June 11, 2017:
1) tested compat with wp 4.8

Mar 27, 2017:
1) changed db table schema which caused problems for sites with lots of posts.

Dec 9, 2016:
1) Ensured compatibility with WP v 4.7

Nov 11, 2016:
1) added plugin icon and banner image. 2) added tip info

Nov 6, 2016:
1) updated screenshot image on wp plugin page.
2) a) added screenshot images on plugin page. b) removed 'console.log' in the front end JS file.

Nov 4, 2016:
1) Fixed some images that were not loading properly.

Nov 3, 2016:
1) initial commit.


1. [Support Forum](https://wordpress.org/support/plugin/pre-party-browser-hints)

2. Send me an email at info@sptrix.com
