10 votes

The Cost of Javascript in 2018

10 comments

  1. [10]
    dyyyl
    Link
    tl;dr: To stay fast, only load JavaScript needed for the current page. Prioritize what a user will need and lazy-load the rest with code-splitting. This gives you the best chance at loading and...

    tl;dr:

    • To stay fast, only load JavaScript needed for the current page. Prioritize what a user will need and lazy-load the rest with code-splitting. This gives you the best chance at loading and getting interactive fast. Stacks with route-based code-splitting by default are game-changers.

    • Embrace performance budgets and learn to live within them. For mobile, aim for a JS budget of < 170KB minified/compressed. Uncompressed this is still ~0.7MB of code. Budgets are critical to success, however, they can’t magically fix perf in isolation. Team culture, structure and enforcement matter. Building without a budget invites performance regressions and failure.

    • Learn how to audit and trim your JavaScript bundles. There’s a high chance you’re shipping full-libraries when you only need a fraction, polyfills for browsers that don’t need them, or duplicate code.

    • Every interaction is the start of a new ‘Time-to-Interactive’; consider optimizations in this context. Transmission size is critical for low-end mobile networks and JavaScript parse time for CPU-bound devices.

    • If client-side JavaScript isn’t benefiting the user-experience, ask yourself if it’s really necessary. Maybe server-side-rendered HTML would actually be faster. Consider limiting the use of client-side frameworks to pages that absolutely require them. Server-rendering and client-rendering are a disaster if done poorly.

    8 votes
    1. [9]
      demifiend
      Link Parent
      Hi. @Deimos posted this article a few days ago, but I'll comment anyway. Articles like this are well and good, but it isn't reasonable to blame put all the blame for bloated web pages on front-end...

      Hi. @Deimos posted this article a few days ago, but I'll comment anyway. Articles like this are well and good, but it isn't reasonable to blame put all the blame for bloated web pages on front-end developers.

      Front-end developers can do everything this article suggested, only to have their efforts made irrelevant by the following:

      • Web fonts
      • Poorly compressed, high-resolution images
      • Auto-playing video
      • Analytics
      • Advertising
      • Modals demanding newsletter signups

      Developers can only push so hard against this bullshit when they aren't unionized and thus cannot go on strike until management heeds their concerns/warnings.

      9 votes
      1. [8]
        dyyyl
        Link Parent
        Oh shoot, I could have sworn I saw this somewhere recently, but I figured it was slack or reddit. On another note then - you mentioned unionization. What do you envision a union doing to help in...

        Oh shoot, I could have sworn I saw this somewhere recently, but I figured it was slack or reddit.

        On another note then - you mentioned unionization. What do you envision a union doing to help in this situation? I'm not disagreeing, but I'm very curious as to how that might work.

        5 votes
        1. [7]
          demifiend
          Link Parent
          I figure tildes will eventually be able to identify previously submitted URLs, but it isn't there yet. :) A single developer can be fired and replaced. A team that isn't part of a wider...

          Oh shoot, I could have sworn I saw this somewhere recently, but I figured it was slack or reddit.

          I figure tildes will eventually be able to identify previously submitted URLs, but it isn't there yet. :)

          What do you envision a union doing to help in this situation?

          A single developer can be fired and replaced. A team that isn't part of a wider organization (like a trade union) can be fired en masse and replaced. A union shop can present a united front when dealing with management, and say, "No, we aren't going to do that," when marketing or editorial makes unreasonable demands.

          1. [4]
            dyyyl
            Link Parent
            Huh, that would be a godsend. So, a union less focused on salary/benefits - more geared toward developer freedom and giving teams with technical background some authority/security in the ideation...

            Huh, that would be a godsend. So, a union less focused on salary/benefits - more geared toward developer freedom and giving teams with technical background some authority/security in the ideation and decision making of a product?

            1 vote
            1. [3]
              demifiend
              Link Parent
              Ideally, a trade union/professional association for developers, database admins, system administrators, tech support personnel, and other tech workers would provide or negotiate for employer...

              So, a union less focused on salary/benefits - more geared toward developer freedom and giving teams with technical background some authority/security in the ideation and decision making of a product?

              Ideally, a trade union/professional association for developers, database admins, system administrators, tech support personnel, and other tech workers would provide or negotiate for employer provision of the following:

              • Ethical guidance
              • Overtime pay or guaranteed time off in lieu
              • Protection from harassment
              • Protection from retaliation for whistleblowers, workers objecting on ethical grounds
              • Burnout prevention measures
              • Treatment for burnout
              • Paid vacation
              • Protection against age discrimination
              • Placement assistance
              • Better working conditions (telework vs open plan offices)
              • Greater autonomy/control over project direction
              • Training in new technologies/continuing education
              1 vote
              1. [2]
                dyyyl
                Link Parent
                Wow, that all sounds incredible! So - how in the world do we make this a reality? On a broader note, how did historically strong unions get to a place where they can make demands like that and...

                Wow, that all sounds incredible! So - how in the world do we make this a reality? On a broader note, how did historically strong unions get to a place where they can make demands like that and win?

                Does this topic deserve its own thread btw? @demifiend, would you be interested in turning the post I'm replying to and turning it into a proper discussion piece on ~comp?

                2 votes
                1. demifiend
                  Link Parent
                  This is a question I can't answer in brief at the moment. I might do so later this week. It might be worth it...

                  Wow, that all sounds incredible! So - how in the world do we make this a reality? On a broader note, how did historically strong unions get to a place where they can make demands like that and win?

                  This is a question I can't answer in brief at the moment.

                  Does this topic deserve its own thread btw? @demifiend, would you be interested in turning the post I'm replying to and turning it into a proper discussion piece on ~comp?

                  I might do so later this week. It might be worth it...

                  2 votes
          2. [2]
            Luna
            Link Parent
            I've heard of strikes for working conditions and pay, but not on behalf of the end user. Are unions a thing in software development?

            I've heard of strikes for working conditions and pay, but not on behalf of the end user. Are unions a thing in software development?

            1 vote
            1. demifiend
              Link Parent
              Unions that focus exclusively on workers interests aren't going to get much support in the US after decades of union-busting efforts by business owners and the Republican Party, so it's time to...

              I've heard of strikes for working conditions and pay, but not on behalf of the end user.

              Unions that focus exclusively on workers interests aren't going to get much support in the US after decades of union-busting efforts by business owners and the Republican Party, so it's time to try a different tack. You've heard of benefit corporations, right? Well, maybe it's time to talk about "benefit unions" as well, unions that not only help workers in a particular trade/industry, but do so in order to better serve the public good.

              Are unions a thing in software development?

              I wish.

              2 votes