Converting Linked Resources to HTTPS Upon Loading the Document Page Using jQuery

This is just a separate post to modifying linked resources to HTTPS when using DOM.

jQuery( document ).ready(function($) {
    // This will find links for `href` attributes and substitute url value
    str.replace(/(href[^http://]+)(?<=['\"])http(?=://)/gi, "$1https")

   // This will look for `src` attributes particularly images, JS scripts and replace the URL value
    str.replace(/(src[^http://]+)(?<=['\"])http(?=://)/gi, "$1https");

    // Find forms and look for `action` attributes and replace url value
    str.replace(/(action[^http://]+)(?<=['\"])http(?=://)/gi, "$1https");

Feel free to comment below;

Elvin is one of the contributors of He has been creating Wordpress Plugins, Magento Extensions, & Mobile Applications. If you find this article useful, please Follow him on .
About Elvin D.
Leave Your Thought