Google Libraries - URL version selecting - javascript

Reading through documentation,
I found following:
1.9.1
1.8.4
1.8.2
A version of "1.8.2" select the
obvious, fully-specified version.
Specifying a version of "1.8" would
select 1.8.4 since this is the highest
version released in the 1.8 branch.
For much the same reason, a request
for "1" loads version 1.9.1, since
this is the highest version released
in the 1 branch. Note, these
versioning semantics work the same way
when using google.load and when using
direct script urls.
Does that mean, that I can use something like
http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
and I get latest jQuery v1.** ?
Or, would it be even possible to include:
http://ajax.googleapis.com/ajax/libs/jquery/jquery.min.js

Well, just testing the two URL you gave :
http://ajax.googleapis.com/ajax/libs/jquery/jquery.min.js
This doesn't work : I get a 404 error.
So, it seems you must specify at least the major version number (i.e. the first digit in 1.4.2) -- which seems reasonable, as a change in major version number generally means a big change in the API (which will probably require you to change stuff in your application).
And with the first one :
http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
I get jQuery 1.4.2 -- which is indeed the most recent version.
And if I test with prototype :
http://ajax.googleapis.com/ajax/libs/prototype/1/prototype.js
I get the most recent version too.

Related

Laravel consoletvs/charts and IE11

I'm using consoletvs/charts to display charts in my Laravel application.
This works fine in all modern browsers, but I get an syntax error (and no charts displayed) in Internet Explorer 11 and below.
Tracing it down it seems this line (from consoletvs/charts, e.g. in init.blade.php line 8) is causing the (initial) error:
data => data.json()
So the culprit is the arrow operator, not supported in IE11. Using a polyfill seems to impossible (see Is there a polyfill for es6 arrow function?).
Now my questions:
Did I miss a feature in consoletvs/charts?
Is there a "Laravel" way to solve this (e.g. using babel/babel)?
Anybody got consoletvs/charts running on IE11?
Looks like you already got the answer to your question from the suggestion you got on the GitHub issues page for ConsoleTVs/Charts.
I will be changing this library to use my other tool:
https://github.com/Chartisan
This have a babel compilation step on the front-end or a pre-compiled
one. Also, the only thing needed will be the fetch() function. This
can be polyfilled.
Just stay tunned. I am writting the docs of Chartisan, and this lib
will soon be ported to that.
Reference:
Syntax Error on IE11 #554
As suggested, you should wait for the docs of Chartisan

How to hide the version of jQuery

I'd like to hide the version of jQuery library used in my project so nobody can see which version is in use (at least just by quick looking at the code).
While removing a JS comment containing jQuery version is fairly easy, there is a variable hardcoded into jQuery which reveals the version:
var ah = "1.11.3"
My wish is to empty the variable, however I'm not a frontened developer so I don't know what could potential consequencies.
Does jQuery uses this variable is some particular way?
So two points:
Yes removing that could have issues, 3rd party plugins will use: jQuery().jquery to get the version to see if the version used is a recent enough version for the plugin to work, if you remove that the plugin could not load or try and work and have massive issues if the version of jquery isn't 'good' enough.
Removing the version won't help in people not being able to identify if they really want to, it just adds a 2 minute step to the process of just comparing the rest of the code to jquery versions.
I would strongly advise not to remove the version number or change it.
I agree with others point but to answer your question . You can remove the version. you can just empty the version string.
var version = " "
If you give this in your source code even if you try to get the version using $.fn.jquery it gives the empty string.
To give more insight:
download the jquery from jquery.com
save it in the same folder where you create your file.
Include the script in your file in the script src tag.
go to the downloaded file and empty the version variable( var version = " ")
Now in your file even if you try to get the version number ,you cant.
Note : Try to not use the vulnerable version.

How to use different version of JQuery on a JS file?

I have a Cisco JS library designed to work using JQuery 1.4.2 and I'm using latest 2.X version of JQuery on the UI page I'm developing.
Cisco Library
I'm using Jabberwerx.js file from the above library link.
The library works fine if the JQuery loaded is of 1.4 but fails to work with later versions of JQuery. If I use old version of Jquery my UI based on bootstrap doesn't work. I tried to use noConflict() but then I can not edit the entire library which is very huge. There are lots of webservice calls and functions on the library so upgrading it is very painstaking.
Is it possible to use a particular version of JQuery on this JS file and the rest of the application can use the latest version of JQuery?
The library has this code on it. Can we change this to make it work using old version of JQ.
(function(window)
{ var jQuery=function(selector,context)
{
return new jQuery.fn.init(selector,context);
},
_jQuery=window.jQuery,
_$=window.$,
}
I'm not looking at using different versions of JQuery on the same page but I'm trying to limit the usage of one version of JQuery to one of the JS files.
When you use different version of jquery then your code conflicts. So there may appear obvious errors.
To fix it, you need to use $.noConflict() passing a boolean parameter true.
jQuery.noConflict(true);
//removes jquery itself and allows you to work with different version of jquery
Example:
<script src="jquery-version-1.0"></script>
<script>//code for v-1</script>
<script>jQuery.noConflict(true);//remove jquery</script>
<script src="jquery-version-2.0"></script><!--use another version-->
<script>//code for v-2</script>
In addition to what Bhojendra Nepal's answer, You can also check the version of jQuery through the following Code :
var jq_version = $().jquery;
console.log(jq_version);
/* gives the version number like 1.7.1. So may be you can write an if condition around the version number. For e.g :*/
if(jq_version == '1.7.1'){
//do something for ver 1.7.1
}
There are even more ways to Check the version of jQuery. But I'm not sure if that would help much with the CISCO library you are using.

Problems testing XHRs/Fetch with Chrome 42 on OS X

We are using Marty.js (and React.js) in our webapp.
As I read in the Marty.js docs they're using the fetch-polyfill to communicate with the server over http. Everything fine so far ...
While testing in Google Chrome (currently v42) first I noticed that the body of the request isn't shown (but sent ?!?) and then that I can't "replay XHR" from the dev-tools.
Can anybody tell me why this is the case?
update 04/26/15
Because it seems to not have anything to do with marty.js I removed it from the question's title.
I believe what you're seeing is related to two issues in MartyJS' github.
https://github.com/martyjs/marty/issues/308 (success function called regardless off http status code returned)
https://github.com/martyjs/marty/issues/293 (martyjs not deserialzing json properly in certain browser setups) <-- this is the one you're having a specific issue with it looks like.
There was an update to the library to fix both of these. I recommend upgrading. We haven't had any problems since grabbing the latest as of a week ago (0.9.14). I believe a new version has already been released (0.9.15) while work on 0.10 is being done in parallel.

Detect version of the plugin in Chrome browser

I have NPAPI plugin and I want to detect its version before I embed it into web page. If version is not the latest one I want to show some message that asks users to update the plugin.
Now it's implemented in the following way
if (navigator.mimeTypes && navigator.mimeTypes["application/myplugin"]) {
{
// some code here
if(navigator.plugins["myplugin"] && navigator.plugins["myplugin"].version >= latest_version) {
// we have the latest version (embed the plugin into web page)
document.write ("<object id='plugin'><embed ....></object>");
} else {
document.write ("Show message here");
}
// some code
}
The problem is that navigator.plugins["myplugin"].version works fine in Firefox but not in Chrome. Chrome doesn't expose version property. I can add my own property in NPAPI code, but I don't see the way I can use it before embedding the plugin into page.
Is there any workaround?
Thanks in advance, Andrew
I see a lot of plugins have version information in either the name or the description. You should be able to access that information before the embed.
I actually put the version number in the filename, rather than even the name or description. The reason for this is that if there are multiple plugins with the same name, description, and mimetypes Firefox will generally use the latest version. Older versions of firefox have been inconsistent in how they handle this, so I even usually put the np???_version.dll file in a version-specific subdirectory.
It is a little bit of a pain, but it works consistently the same way in every NPAPI browser.
You can create a JSAPI property of your plugin containing the version. This property returns the plugin's version when called from javascript. So when you try to insert/embed the plugin in the page, you can check through javascript to make the appropriate calls.

Categories