Prevent deletion of specific icons from dock

I regularly accidentally drag the Downloads folder from the dock to trash when trying to delete a recently downloaded file, removing it from he dock.

Is there any way to disable dragging and deleting icons from the dock? An equivalent of locking a file but for individual dock icons?

I don't want to lock the entire dock, just specific icons.


I don't think it is possible to lock specific icons.

To lock all the icons go to Terminal and type:

defaults write com.apple.Dock contents-immutable -bool yes

Press enter then type:

killall Dock