1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Lack of Interest Move most of jQuery.extend to external file

Discussion in 'Closed Suggestions' started by Marcus, Oct 25, 2013.

  1. Marcus

    Marcus Well-Known Member

    Most of that javascript, with the exception of some very minor data might be put into an external file:
    visitor: { user_id166 },
    color"rgb(255, 255, 255)",
    _ignoredUsers: {"1":"a","2":"b"},
    _loadedScripts: {"node_list":true,"node_category":true,"node_forum":true,"node_link":true,"node_page":true,"sidebar_share_page":true,"xfcom_page_wrapper":true},
    _cookieConfig: { path"/"domain""prefix"xf_"},
    a_moment_ago"A moment ago",
    one_minute_ago"1 minute ago",
    x_minutes_ago"%minutes% minutes ago",
    today_at_x"Today at %time%",
    yesterday_at_x"Yesterday at %time%",
    day_x_at_time_y"%day% at %time%",
    following_error_occurred"The following error occurred",
    server_did_not_respond_in_time_try_again"The server did not respond in time. Please try again.",
    logging_in"Logging in",
    click_image_show_full_size_version"Click this image to show the full-size version.",
    show_hidden_content_by_x"Show hidden content by {names}"
    // Facebook Javascript SDK
    XenForo.Facebook.appId "146201428725181";
    XenForo.Facebook.forceInit true;
  2. xf_phantom

    xf_phantom Well-Known Member

    You can't move anything of this into a static file;)

    this variables are
    • phrases
    • xenforo options
    • other dynamic variables (like visitor data)
    The phrases "could" be moved to an automatic generated JS file, but not sure if it's worth because of all the possible troubles like the write permissions for the files

    and the files would also probably be REALLY big, which could cause performance problems when you load them the first time. (and you would need to rebuild them after each phrase CRUD operation like addon installation, addon deinstallation, phrase edit via acp)
    Last edited: Oct 25, 2013
    Marcus likes this.
  3. Marcus

    Marcus Well-Known Member

    Maybe one could put this in an external file setting-{$latest-setting-id}:

    _lightBoxUniversal: "1",_enableOverlays: "1",_animationSpeedMultiplier: "1",_overlayConfig:
    {top: "10%",speed: 200,closeSpeed: 100,mask:
    {color: "rgb(255, 255, 255)",opacity: "0.6",loadSpeed: 200,closeSpeed: 100}

    _lightBoxUniversal: "1",_enableOverlays: "1",_animationSpeedMultiplier: "1",_overlayConfig:
    {top: "10%",speed: 200,closeSpeed: 100,mask:
    {color: "rgb(255, 255, 255)",opacity: "0.6",loadSpeed: 200,closeSpeed: 100}

    And this in a file phrase-[$language-id}.js per language :

    {cancel: "Cancel",a_moment_ago: "A moment ago",one_minute_ago: "1 minute ago",x_minutes_ago: "%minutes% minutes ago",today_at_x: "Today at %time%",yesterday_at_x: "Yesterday at %time%",day_x_at_time_y: "%day% at %time%",day0: "Sunday",day1: "Monday",day2: "Tuesday",day3: "Wednesday",day4: "Thursday",day5: "Friday",day6: "Saturday",_months: "January,February,March,April,May,June,July,August,September,October,November,December",_daysShort: "Sun,Mon,Tue,Wed,Thu,Fri,Sat",following_error_occurred: "The following error occurred",server_did_not_respond_in_time_try_again: "The server did not respond in time. Please try again.",logging_in: "Logging in",click_image_show_full_size_version: "Click this image to show the full-size version.",show_hidden_content_by_x: "Show hidden content by {names}"});
  4. Chris D

    Chris D XenForo Developer Staff Member

    Then, all of a sudden, you've created a whole load of additional work for developers, an inability for add-on developers to extend XenForo.phrases easily (as we need to sometimes), a whole load of additional complexity for translators all for something that, overall, is incredibly minute in performance benefit.
  5. Marcus

    Marcus Well-Known Member

    If I change the phrase monday to "lunes" within the language "spanish ID 5", the file phrase-5.js would be updated to the new content. From what I understand addon developers would not have to touch this.

    If phrases gets added, they will also be added to phrase-[$language-id}.js within the xenforo acp phrase system.

    I am very eager to learn more about xenforo and I am happy to be teached more about the functionality, from my understanding this idea would work.
  6. Teapot

    Teapot Well-Known Member

    Whether it works or not is somewhat irrelevant - the costs outweigh the benefits. You're sacrificing simplicity and flexibility for externalising more of the JS. In this instance, you're simply complicating an issue that shouldn't require a lot of IO activity just for the sake of rendering a page without inline JS.

    I'd like to throw the question back to you in case I'm making undue assumptions: why would we want to do this? What benefits would you feel this brings to the XenForo software?
    Chris D likes this.
  7. Marcus

    Marcus Well-Known Member

    Thanks for giving more information on how the xenforo system works, I learn a lot from it!


Share This Page