This feels like a stupid question, but there’s plenty of techniques out there that more expert coders use that I don’t know about. How do you preserve minor or major changes you may have made to a script made by someone else while still being able to update any new changes they have? Besides the obvious way of saving your changes somewhere and reinserting them.

  • curiosityLynx@kglitch.social
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    For CSS, this is pretty easy:
    Leave the original source alone, and make your modifications (and only the modifications) in a separate file that is loaded after the original source.

    Example
    Say the original source style has something like this:

    a:hover {
        color:green;
        text-decoration:underline;
    }
    
    

    and you want to remove that underline.
    Just put the following in your modifications file:

    a:hover {
        text-decoration:none;
    }
    
    

    Links will continue to become green when you hover over them, but they will no longer get underlined when you hover over them.

    If you can’t guarantee that your modifications will get loaded after the original, add !important like this:

    a:hover {
        text-decoration:none !important;
    }
    
    
    • Rhaedas@kbin.socialOP
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      Good point for CSS changes since they can override the previous (usually). Some of my changes are in the JS functions though. I may just stick to the “hard” way, after all we may see some of this get wrapped into the base code eventually.