Wamp not recognizing a change in my code? - javascript

I'm working with Wamp, and i just added a console.log line.
console.log("message);
However, the message isn't being displayed in the console. After a bit of research, i found out that the source code of the page displayed on my browser ISN'T including the console.log line.
It seems like Wamp isn't recognizing the changes in my code all of a sudden.
I tried restarting it but still the same issue. Any ideas ?

This is javascript you are amending. Javascript is cached in the browser, so if you make a javascript change on the server it is sometimes necessary to tell your browser to refresh all its cache's.
You do this by loading the page you want to see and then pressing CTRL+F5 (both together) The browser will reload the page and all its resources, bringing up your amended javascript from the server in the process.

Related

How to run JavaScript code continously in browser console even after page reload

I am trying to run a JavaScript code, something like this document.getElementById('someID').innerHTML = ''; in a web browser console. It works fine until the page is refreshed or redirected to another page. Soon after the page refreshes the console gets erased, and I have to manually run it again. Is there a way to run JavaScript code continuously in the browser console even after the page reloads, or is there any other way (externally from the browser console) to accomplish the above task?
You can try tamper monkey there are chrome and firefox versions https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=en
GreaseMonkey is one more option for Firefox to run external js along with page loaded js

Script keeps timing WP site out. Any ideas where it comes from

enter image description here
This script is generated by chrome. It runs till it times out the site. Any idea where it is coming from? or what is causing?
Do you have any extensions installed? If you do, that's probably why. Looking at how the page is loading a url from the chrome resource, it's probably a corrupted chrome extension. Try disabling each extension you have one by one, to see which one is causing the problem.

Duplicated Mapped Javascript Source not Saving Changes on Chrome's Dev Tools

I'm making a local web page (.html) that loads a few .js files and am having trouble using Google Chrome's Developer Tools.
Definition
The problem I'm having has to do with the Source Panel: I have one source tab open with a specific file and when I open this file by clicking the console or the source file at the left, randomly a duplicate is created instead of just redirecting it to the one already open.
Both will have the same file-path:
Both will allow me to write and save the file (even showing/hiding the asterisk correctly)
Only one of them will correctly save the contents to disk.
I have to fix it by closing both files and opening it again, but sometimes I can't see that there is a duplicated file and it causes me to fix a problem only to find out that the file wasn't actually saved, reverting completely every change I made to that file when I refresh the page.
Example of the problem
The most common appearance of the bug is when I'm doing the following:
I identify a console.warn / console.error / syntax error log in the console
I click the line that caused that log (at the rightmost of the console) and I'm redirected to the source panel, where a new source file tab opens and I begin editing it.
Somewhere in the source tabs is another source file of that same file (with the same filepath): That tab should be the one I was editing: only this original tab will correctly save changes made to the file.
I fix the random javascript problem in the file that I was lead to by clicking the console.
I hit Ctrl+S (or Right Click > Save), the asterisk that indicates a unsaved file disappears. At that point Chrome expects to have saved the file successfully, but it didn't (I can check by opening the file in Notepad)
I hit F5 to refresh the page.
Chrome loads the old, unsaved file, erasing all the changes I made in the source file.
Sometimes the very same steps doesn't create a duplicate file, but all I have to do is refresh and try again until it does. Recreating this bug is a matter of chance, I can't predict or pinpoint its causes either.
When refreshing the page with the Dev Tools open, there's a small chance that it will creates a broken mapping, where the mapped project becomes only partially mapped
even though it was fine seconds before: (only restarting chrome fixes that)
This last paragraph may or may not have something to do with the problem but I can clearly select and open the "fake" file and the "real" file even though they have the same file path.
I made this gif to show how the file paths are identical to each other in the Dev Tools: http://i.imgur.com/ULlbskO.gif
Details of the setup
I'm using the local file system (file:///) strictly, there is no localhost or server being used to host my application, it is pure HTML + Javascript.
I'm using Google Chrome 57 for Windows without any extensions, but I've been having that problem since December, 2016.
My project was mapped by adding the folder to the workspace and mapping it to a local file, which used to work in the past.
Here's a picture of my configurations: http://i.imgur.com/IEmE3zG.png
Things I've tried
Clearing Chrome's Cache
Removing the project from the Source Panel workspace and adding it again
Reinstalling Chrome
Moving the project path to somewhere else
Searching on Google
Letting go / Accepting defeat (I've grown too dependent on the tool)
Waiting 2 months for someone to have this problem too and post it somewhere in the internet
Questions I need help with
Can I minimize/fix this problem in any way?
Has anyone dealt with this before?
Does someone know if this is a Chrome bug or am I doing something wrong with my workflow?
Found the answer myself after several months working with web development.
The duplicated file has been fixed in Chrome since the time I made this question, but files keep loosing "connection" with the local file system (green dot that marks them as sync'd with local) randomly, which made me investigate and I finally found the reason:
What's happening is that Dev Tools is trying to save the file and, when it retrieves it it loads from cache (because my local web server was sending cache-specific headers), which makes the browser think that file file is not actually the one it saved, so it stops its syncronization!
To solve it, all I had to do is ensure my local web server is disabling any form of cache for my javascript files, which I can check from the network panel:
My local web server was sending cache headers for 1 hour, which made chrome open the cached file, which was different from my edited file which was an indication that the file is not the one it saved.
After changing the server to serve static content without the cache headers, everything went smoothly and files kept sync'd correctly!

Localhost not recording changes to code?

I'm making changes locally to my code. When I save the code in Atom, then refresh over localhost, the changes are not being displayed in the browser. What are the possible reasons for this?
Not really a solution, but mistakes that I sometimes do:
1. Cross check carefully if its the same file that your are editing, and the one that's run in the terminal, and browser.
2. Also carefully check, when you save the file, is the terminal refreshing the client, or restarting the server.
I have highlighted carefully, because it's happened to me, and I have seen it happen with my colleagues.
try ctrl+f5 to refresh browser.
or open dev tool in browser then check "disable cache" on settings (chrome)
If clearing cache resolves issue, then from next time you can use browser in incognito, or use this chrome ext https://chrome.google.com/webstore/detail/cache-killer/jpfbieopdmepaolggioebjmedmclkbap
Clear cache in the browser, check to make sure Atom is saving the file in the right place and not else where on the computer other things to try is edit the file in notepad or notepad++ and save it and see if it changes. As it could be atom its self not working correctly..

Ruby On Rails - When I hit back I only see Javascript code?

When going back on my latest app I can only see the code from one of my javascript files that I've included in the assets/javascripts?
If I then try to hit reload it renders the page as I would like it to be.
I just noticed that the same thing occur when I hit forward on my application.
Something with the cache?

Categories

Resources