-6

how can I make a bookmark that installs jquery?

so that when I am in the developer console, I can call jquery functions from whatever websites i'm on?

barlop
  • 12,887
  • 8
  • 80
  • 109
  • You could always write a userscript that injects jquery into the page. – Taplar Jul 15 '19 at 14:59
  • Firstly if you Google the title of this question you get multiple answers. Secondly, what do you do if the page has a version of jQuery in it already but it's a lower version than you need? I'd suggest using plain old JS for bookmarklets to save a whole load of avoidable headaches. – Rory McCrossan Jul 15 '19 at 15:01
  • 1
    @RoryMcCrossan expect in this case the whole point of the bookmark appears to be to add jQuery to the page so the user can hack around with the page using jQuery in the console. So "using plain old JS" is counter to that desired result. – Taplar Jul 15 '19 at 15:03
  • @Taplar true. I read the question as though the installation of jQuery was a means to an end within the bookmarklet itself. – Rory McCrossan Jul 15 '19 at 15:05
  • @RoryMcCrossan you misunderstood the question then. Taplar has it correct – barlop Jul 15 '19 at 15:07
  • The first part of my comment is still accurate – Rory McCrossan Jul 15 '19 at 15:08

1 Answers1

-2

I have such a bookmark, I did see the solution somewhere in a comment somewhere on SO once..

javascript:!function(){var jq = document.createElement('script'); jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"; document.getElementsByTagName('head')[0].appendChild(jq); /*jQuery.noConflict();*/}();

you can update it to the latest jquery

a similar thing is mentioned https://tutel.me/c/programming/questions/7474354/include+jquery+in+the+javascript+console

barlop
  • 12,887
  • 8
  • 80
  • 109