Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8237341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:26:32+00:00 2026-06-07T19:26:32+00:00

I created an externs file to be able to compile the jQuery Star Rating

  • 0

I created an externs file to be able to compile the jQuery Star Rating Plugin fyneworks.com/jquery/star-rating/#tab-Testing with Google Closure Compiler’s ADVANCED_OPTIMIZATIONS.

But, even though I reference the standard jQuery extern, the ‘$’ is getting renamed which breaks the plugin.

Perhaps related: if I use the unmodified plugin, ‘rating’ also gets renamed. I can fix that part with:

$.fn['rating'] = function(opts) {

from google closure compile jQuery Plugin … but that doesn’t fix ‘$’ (and it would be nice to use the unmodified plugin if possible).

from my attempt at an extern (which is probably wrong and/or incomplete):

// ??? for '$'

// this one does NOT prevent 'rating' from being renamed
function rating(arg1) {}

// the following seem to work: they prevent the functions from being renamed
rating.focus = function() {}
rating.blur = function() {}
rating.fill = function() {}
... etc.

command line (and rating.sh in the download):

java -jar ../compiler-latest/compiler.jar --formatting pretty_print --compilation_level ADVANCED_OPTIMIZATIONS --externs externs/jquery-1.7.js --externs externs/jquery.rating-extern.js --js original/jquery.rating.js --js_output_file jquery.rating.gcc.js

error messages:

Firefox:
$(".star1").rating is not a function
callback: function (value) {
jquery.ratingSampleCode.js (line 9)

Chrome:
Uncaught TypeError: Object [object Object] has no method 'rating'
jquery.ratingSampleCode.js:8

from my sample code:

$('.star1').rating({
    callback: function (value) {

To test: http://prefabsoftware.com/test/rating-july15/

To download: prefabsoftware.com/test/rating-july15.zip

Some useful links: (which I’m not allowed to specify as markdown since I couldn’t login with my old reputation points…)

  • Advanced Compilation and Externs: developers.google.com/closure/compiler/docs/api-tutorial3#externs
  • sample externs: contrib: code.google.com/p/closure-compiler/source/browse/#svn%2Ftrunk%2Fcontrib%2Fexterns) including jQuery itself, but not the rating plugin
  • more externs: code.google.com/p/closure-compiler/source/browse/#svn%2Ftrunk%2Fexterns

Is there a simple fix for the extern? Or a better solution?

Thanks!


Ok, this works for the externs file:

$.prototype.rating = function(arg1) {}
jQuery.prototype.rating = function(arg1) {}

$.prototype.rating.focus = function() {}
... etc.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:26:34+00:00Added an answer on June 7, 2026 at 7:26 pm

    From your description, you appear to be using an extern file improperly. An extern file for your plugin would allow other users to compile code referencing your plugin. It shouldn’t be used to compile your actual plugin code at all. To compile your code, you would only need the jQuery extern file.

    jQuery code styles have known issues with Closure-compiler. In particular, you would need to avoid the following:

    • Any use of the $ alias. Use the full jQuery namespace. The compiler doesn’t handle aliased namespaces well.
    • The jQuery.fn alias. Instead use jQuery.prototype.
    • Use of the jQuery.extend method to add function prototypes or public methods. Instead, add them directly to the prototype. (example: jQuery.fn.extend({a: 'foo'}); would become jQuery.prototype.a = 'foo';);

    With ADVANCED_OPTIMIZATIONS, keep in mind that you will still have to export or quote any public methods and prototypes. This may mean that SIMPLE_OPTIMIZATIONS turn out to be a better fit for your project.

    For more information, see http://blogs.missouristate.edu/web/2011/02/14/jquery-plugins-and-closure-compiler/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Created basic C++ DLL and exported names using Module Definition file (MyDLL.def). After compilation
I've created shared library (will be used like plugin). There are a lot of
I've created both a static lib and an EXE file (which uses the static
I have a C# winapp. I call a native .dll file (created in C++
Suppose I created a header file constants.h and this file contains: extern const int
I have a library I created, File mylib.c: #include <mylib.h> int testlib() { printf("Hello,
I have created a .c file which is being converted to a .o file
I am trying to annotate my Javascript properly in order to avoid Google Closure
Created .NET WCF service, tested it - works. Generated schemas from Data and service
Created Private Key & Self signed certficate in a Key Store keytool -genkey -alias

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.